package com.nbsaas.boot.marketing.rest.resource;

import com.nbsaas.boot.marketing.api.apis.FlashSaleApi;
import com.nbsaas.boot.marketing.data.entity.FlashSale;
import com.nbsaas.boot.marketing.api.domain.request.FlashSaleRequest;
import com.nbsaas.boot.marketing.api.domain.response.FlashSaleResponse;
import com.nbsaas.boot.marketing.api.domain.simple.FlashSaleSimple;
import com.nbsaas.boot.marketing.rest.convert.FlashSaleSimpleConvert;
import com.nbsaas.boot.marketing.rest.convert.FlashSaleEntityConvert;
import com.nbsaas.boot.marketing.rest.convert.FlashSaleResponseConvert;
import com.nbsaas.boot.marketing.data.repository.FlashSaleRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   秒杀活动-业务接口实现
*/
@Transactional
@Service
public class FlashSaleResource extends BaseResource<FlashSale,FlashSaleResponse, FlashSaleSimple, FlashSaleRequest>  implements FlashSaleApi {

    @Resource
    private FlashSaleRepository flashSaleRepository;

    @Override
    public JpaRepositoryImplementation<FlashSale, Serializable> getJpaRepository() {
        return flashSaleRepository;
    }

    @Override
    public Function<FlashSale, FlashSaleSimple> getConvertSimple() {
        return new FlashSaleSimpleConvert();
    }

    @Override
    public Function<FlashSaleRequest, FlashSale> getConvertForm() {
        return new FlashSaleEntityConvert();
    }

    @Override
    public Function<FlashSale, FlashSaleResponse> getConvertResponse() {
        return new FlashSaleResponseConvert();
    }




}


